//Window Class Source File
//Class for managing the opening and closing of windows

	//Include Files//
#include "Window.hpp"

	//Globals & Constants//


Window::Window()
{
	m_GameName		= "Default_Game_Name";
	m_WindowName	= "Default_Window_Name";
	m_ScreenWidth	= 480;
	m_ScreenHeight	= 480;
	m_WindowOpen	= false;
}

HWND Window::OpenWindow(int nCmdShow, HWND hWnd, HINSTANCE hInstance)
{
	//Variables
	WNDCLASSEX WinClass;						//The WNDCLASSEX structure is similar to the WNDCLASS structure. There are two differences. WNDCLASSEX includes the cbSize member, which specifies the size of the structure, and the hIconSm member, which contains a handle to a small icon associated with the window class.

		//Initialize
	hWnd =  NULL;								//Reset hWnd
	
	WinClass.cbClsExtra		= 0;
	WinClass.cbSize			= sizeof(WNDCLASSEX);
	WinClass.cbWndExtra		= 0;
	WinClass.hbrBackground	= (HBRUSH)GetStockObject(BLACK_BRUSH);
	WinClass.hCursor		= LoadCursor(NULL, IDC_CROSS);
	WinClass.hIcon			= (HICON)LoadImage(hInstance, NULL, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
	WinClass.hIconSm		= (HICON)LoadImage(hInstance, NULL, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
	WinClass.hInstance		= hInstance;
	WinClass.lpfnWndProc	= WindowProc;
	WinClass.lpszClassName	= m_WindowName;
	WinClass.lpszMenuName	= NULL;
	WinClass.style			= CS_HREDRAW | CS_VREDRAW;
	
	if(RegisterClassEx(&WinClass) == false)
		{return NULL;}

	hWnd = CreateWindowEx(	NULL,
							m_WindowName,
							m_GameName,
							WS_OVERLAPPEDWINDOW,
							0,
							0,
							m_ScreenWidth,
							m_ScreenHeight,
							NULL,
							NULL,
							GetModuleHandle(NULL),
							NULL);

	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);
	m_WindowOpen = true;

	return hWnd;
}

void Window::CloseWindow()
{
	m_WindowOpen = false;
}

bool Window::WindowOpen()
{
	return m_WindowOpen;
}

Window::~Window()
{

}


/**********************************************************************************************************************\
|	WindowProc:		Processes Window Messages into Windows Actions																	   |
\**********************************************************************************************************************/
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
	case WM_CREATE:
					break;

	case WM_PAINT:
					break;

	case WM_CLOSE:	PostQuitMessage(0);
					break;

	case WM_KEYUP:	switch(wParam)
					{
					case VK_ESCAPE: PostQuitMessage(0);
					}
					break;
	}

	return DefWindowProc(hWnd, uMsg, wParam, lParam);
}	//End WindowProc()